<template>
  <div id="digital-flop">
    <div
      v-for="item in digitalFlopData"
      :key="item.title"
      class="digital-flop-item"
      @click="getShowDialog(item.title)"
    >
      <div class="digital-flop-title">{{ item.title }}</div>
      <div class="digital-flop">
        <dv-digital-flop
          :config="item.number"
          style="width:100px;height:50px;"
        />
        <div class="unit">{{ item.unit }}</div>
      </div>
    </div>
    <dv-decoration-10 />

    <el-dialog
      v-dialogDrag
      :title="title"
      :visible.sync="dialogVisible"
      append-to-body
      width="60%"
      class="dialogWrap"
    >
      <div class="dialogClass" style="overflow-y:auto">
        <scrollBoard />
        <!-- <table-common
          :menu-id="menuId"
          :form-guid="formGuid"
          :is-show="false"
        /> -->
      </div>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
import { commonMethod } from '@/api/mapper/index.js';
// import tableCommon from '@/components/tableCommon/index.vue';
import scrollBoard from './scrollBoard1';
export default {
  name: 'DigitalFlop',
  components: {
    // tableCommon
    scrollBoard
  },
  provide: {
    isShow: false
  },
  data() {
    return {
      digitalFlopData: [],
      dialogVisible: false,
      title: '',
      menuId: '',
      formGuid: ''
    };
  },
  mounted() {
    const { createData } = this;

    createData();

    // setInterval(createData, 3000);
  },
  methods: {
    getShowDialog(title) {
      this.title = title;
      const loading = this.$loading({
        lock: true,
        text: '读取数据中....',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(() => {
        loading.close();
        this.dialogVisible = true;
        if (title === '年度场景总数') {
          this.menuId = 1623395792097;
        } else if (title === '场景总投资总额') {
          this.menuId = 1623396058321;
        } else if (title === '当年累计完成投资') {
          this.menuId = 1623396100220;
        }
      }, 1000);
    },
    async createData() {
      // const { randomExtend } = this;
      const num = [];
      const num1 = [];
      const num2 = [];
      await commonMethod({
        filterList: [],
        pageIndex: 0,
        pageSize: 100,
        pageType: 1,
        tableId: 483
      }).then(res => {
        num.push(res.data[0].NUM);
        num1.push(res.data[0].NUMB);
        num2.push(res.data[0].NUMC);
      });

      this.digitalFlopData = [
        {
          title: '年度场景总数',
          number: {
            number: num,
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#4d99fc',
              fontWeight: 'bold'
            }
          },
          unit: '个'
        },
        {
          title: '场景总投资总额',
          number: {
            number: num1,
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#f46827',
              fontWeight: 'bold'
            }
          },
          unit: '亿'
        },
        {
          title: '当年累计完成投资',
          number: {
            number: num2,
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#40faee',
              fontWeight: 'bold'
            }
          },
          unit: '亿'
        }
      ];
    },
    randomExtend(minNum, maxNum) {
      if (arguments.length === 1) {
        return parseInt(Math.random() * minNum + 1, 10);
      } else {
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
#digital-flop {
  position: relative;
  height: 15%;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(6, 30, 93, 0.5);

  .dv-decoration-10 {
    position: absolute;
    width: 95%;
    left: 2.5%;
    height: 5px;
    bottom: 0px;
  }

  .digital-flop-item {
    cursor: pointer;
    width: 33.3%;
    height: 80%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-left: 3px solid rgb(6, 30, 93);
    border-right: 3px solid rgb(6, 30, 93);
  }

  .digital-flop-title {
    font-size: 20px;
    margin-bottom: 20px;
  }

  .digital-flop {
    display: flex;
  }

  .unit {
    margin-left: 10px;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    padding-bottom: 13px;
  }
}
 .dialogWrap /deep/ .el-dialog__header {
      border-bottom: 1px solid #cec9c9;
      padding: 10px;
      background-color: #0840a9 !important;
    }
     .dialogWrap /deep/ .el-dialog__title {
      line-height: 24px;
      font-size: 18px;
      color: #fff !important;
      font-weight: bolder;
    }
    .dialogWrap /deep/ .el-dialog__body {
    padding: 0px;
    color: #606266;
    font-size: 15px;
    }

</style>
